package com.yckj.day10;

import java.util.Arrays;

/**
 * TODO
 *
 * @author shengyuee
 * @version 1.0
 * 2025/7/29 15:15
 */
public class ArraysDemo {
    public static void main(String[] args) {
        int[] a = {51, 32, 23, 14, 45};
        // 以字符串的形式输出数组
        System.out.println(Arrays.toString(a));
        // 排序
        Arrays.sort(a);
        System.out.println(Arrays.toString(a));
        // 扩容
        a = Arrays.copyOf(a, a.length + 1);
        System.out.println(Arrays.toString(a));
        a[a.length-1] = 90;
        System.out.println(Arrays.toString(a));
        // 二分查找
        int index = Arrays.binarySearch(a, 45);
        System.out.println(index);
        int index2 = Arrays.binarySearch(a, 100); // 找不到返回小于0的值
        System.out.println("index2 = " + index2);

    }
}
